package com.shop.util;

import com.shop.vo.DayStatis;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @ClassName MyUtil
 * @Author xiao宋
 * @Date 16:13  2022/10/18
 * @Version 1.0
 * @Description 自用工具类
 */
public class MyUtil {

    /**
     * <b>下面几个是工具类<b>
     */
    public static List<String> unionDayDate(List<String> dayData, List<String> userDayStatis) {
//        汇总两个   时间   数组
        Set<String> set=new HashSet<>();
        set.addAll(dayData);
        set.addAll(userDayStatis);
//        转 list
        List<String>list=new ArrayList<>();
        list.addAll(set);
//        排序并返回
        Collections.sort(list);
        return list;
    }
    public static List<Integer> fetchCntData(List<DayStatis> orderDayStstis, List<String> dayData) {
        List<Integer>list=new ArrayList<>();
        for (String day : dayData) {
            for (DayStatis ststi : orderDayStstis) {
                if (day.equalsIgnoreCase(ststi.getDayStr())){
                    list.add(ststi.getCnts());
                }
            }
        }
        return list;
    }
    public static List<BigDecimal> fetchAmtData(List<DayStatis> orderDayStstis, List<String> dayData) {
        List<BigDecimal>list=new ArrayList<>();
        for (String d : dayData) {
            for (DayStatis o :orderDayStstis){
                if (d.equalsIgnoreCase(o.getDayStr())){
                    list.add(o.getAmts());
                }
            }
        }
        return list;
    }
    public static List<String> fetchDaySty(List<DayStatis> orderDayStstis) {
        List<String>list=orderDayStstis.stream().map(orderDayStstis1->{
            return orderDayStstis1.getDayStr();
        }).collect(Collectors.toList());

        // 排序
        Collections.sort(list);
        return list;
    }

}
